package mapreduce;

import com.google.inject.internal.cglib.core.$LocalVariablesSorter;
import com.google.inject.internal.util.$ImmutableMap;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.fs.Path;
import org.apache.hadoop.io.Text;
import org.apache.hadoop.mapreduce.Job;
import org.apache.hadoop.mapreduce.lib.input.FileInputFormat;
import org.apache.hadoop.mapreduce.lib.output.FileOutputFormat;
import warningreportcount.ReportCount;

import java.util.*;

public class ReportCountJob {
    public static void main(String[] args) {
        Configuration conf = new Configuration();

        conf.set("mapreduce.framework.name", "yarn");
        conf.set("yarn.resourcemanager.hostname", "master");
        conf.set("mapreduce.job.jar", "HadoopClient.jar");

        try {
            Job job = Job.getInstance(conf, "ReportCount");
            job.setJarByClass(ReportCountJob.class);
            job.setMapperClass(ReportCountMapper.class);
            job.setPartitionerClass(ReportCountPartioner.class);
            job.setReducerClass(ReportCountReducer.class);
            job.setOutputKeyClass(Text.class);
            job.setOutputValueClass(ReportCount.class);
            job.setNumReduceTasks(10);
            FileInputFormat.addInputPath(job, new Path("/test"));
            FileOutputFormat.setOutputPath(job, new Path("/testResult"));
            System.exit(job.waitForCompletion(true) ? 0 : 1);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}
